

$('.back').onclick=function(){
    return history.go(-1)
}
$('.shuaxin').onclick=function(){
    return history.go(0)
}
$('.login').onclick=function(){
    var userName=$('.userName').value.trim()
    var userPsd=$('.userPsd').value.trim()
    var userTel=$('.userTel').value.trim()
    var code=$('.code').value.trim()
    // randomCode()
    if(!userName)return alert('请输入用户名')
    if(!userPsd) return alert('请输入密码')
    if(!isNaN(userPsd)) return alert('密码不能为纯数字')
    if(userPsd.length>8||userPsd.length<6)return alert('请输入6-8位密码')
    if(!userTel) return alert('请输入手机号')
    if(isNaN(userTel)) return alert('手机号为纯数字')
    if(userTel.length!==11)return alert('请输入11位手机号')
    if(code.toLowerCase()!==$('.codes').innerHTML.toLowerCase)  {
        alert('请输入正确的验证码')
        randomCode()
        return
    }
    return location.href='./success.html?userName='+userName
}
randomCode()
    function randomCode(){
        var codeStr = "3214698705QWERTYUIOPLKJHGFDSAZXCVBNMmnbvcxzasdfghjklpoiuytrewq";
        var resStr = ""
        for(var i = 0; i < 4 ; i++){
            var index = Math.floor(Math.random() * codeStr.length);
            resStr += codeStr[index]
        }
        // return resStr
        $('.codes').innerHTML=resStr
    }
    // console.log(randomCode())
